In [3]:
# Import necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
In [28]:
# Load the dataset
car_sales = pd.read_csv('C:/Users/aveda/Downloads/Car Sales.xlsx.csv')
# Data Exploration
car_sales.describe()


# Distribution Visualization
plt.figure(figsize=(10, 6))
sns.histplot(car_sales['Price ($)'], bins=20, kde=True)
plt.title('Distribution of Car Prices')
plt.xlabel('Price ($)')
plt.ylabel('Frequency')
plt.show()
In [20]:
# Categorical Data Analysis
plt.figure(figsize=(12, 6))
sns.countplot(x='Color', data=car_sales)
plt.title('Distribution of Car Colors')
plt.xlabel('Color')
plt.ylabel('Count')
plt.show()
In [21]:
# Dealer Analysis
dealer_counts = car_sales['Dealer_Name'].value_counts()
plt.figure(figsize=(12, 6))
dealer_counts.plot(kind='bar')
plt.title('Number of Cars Sold by Each Dealer')
plt.xlabel('Dealer Name')
plt.ylabel('Number of Cars Sold')
plt.show()
In [22]:
# Price vs. Engine Type
plt.figure(figsize=(12, 6))
sns.boxplot(x='Engine', y='Price ($)', data=car_sales)
plt.title('Price Distribution by Engine Type')
plt.xlabel('Engine Type')
plt.ylabel('Price ($)')
plt.show()
In [23]:
# Transmission Type Comparison
plt.figure(figsize=(10, 6))
sns.barplot(x='Transmission', y='Price ($)', data=car_sales)
plt.title('Average Price by Transmission Type')
plt.xlabel('Transmission Type')
plt.ylabel('Average Price ($)')
plt.show()
In [24]:
# Region-wise Analysis
plt.figure(figsize=(10, 6))
car_sales['Dealer_Region'].value_counts().plot(kind='pie', autopct='%1.1f%%')
plt.title('Distribution of Dealers by Region')
plt.show()
In [25]:
# Correlation Analysis
plt.figure(figsize=(10, 8))
sns.heatmap(car_sales.corr(), annot=True, cmap='coolwarm')
plt.title('Correlation Heatmap')
plt.show()
In [26]:
# Interactive Dashboard (using Plotly)
fig = px.scatter(car_sales, x='Engine', y='Price ($)', color='Color', size='Price ($)',
                 hover_data=['Dealer_Name', 'Body Style'])
fig.update_layout(title='Interactive Dashboard', xaxis_title='Engine', yaxis_title='Price ($)')
fig.show()
In [ ]: